package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.mapper.EmpMapper;
import com.itheima.mapper.StudentMapper;
import com.itheima.pojo.Student;
import com.itheima.service.EmpService;
import com.itheima.service.ReportService;
import jakarta.el.LambdaExpression;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private EmpMapper  empMapper;

    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private EmpService empService;
//员工职位人数统计
    @Override
    public Map empJobCount() {
        List<Map> list = empMapper.empJobCount();

        // 将list集合转换为map集合
        Map map = new HashMap();
        map.put("jobList",list.stream().map(item->item.get("name")).collect(Collectors.toList()));
        map.put("dataList",list.stream().map(item->item.get("value")).collect(Collectors.toList()));
        return map;
    }

    //员工性别人数统计
    @Override
    public List<Map> empGenderData() {
        return empMapper.empGenderData();
    }

    //学员学历统计
    @Override
    public List<Map> studentDegreeData() {
        return studentMapper.studentDegreeData();
    }

    //班级人数统计
    @Override
    public Map studentCountData() {
        List<Map> list= studentMapper.studentCountData();
        Map map = new HashMap();
        map.put("clazzList",list.stream().map(item->item.get("name")).collect(Collectors.toList()));
        map.put("dataList",list.stream().map(item->item.get("value")).collect(Collectors.toList()));
        return map;
    }
}
